<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    <title>Ruby Exception Handling</title>

    <script src="../../js/jquery.js" type="text/javascript"></script>
    <script src="../../js/gestalt.js" type="text/javascript"></script>

</head>
<body>

<script language="ruby">
include System::Diagnostics     # enables outputing to a debug window
include System

def button_click(s, a)
    begin
        x = 1 / 0 # divide by zero to cause exception
    rescue => e
		#window.alert e.message
        Debug.WriteLine e.message
    ensure
		Debug.WriteLine "this line runs no matter what happens"
    end
end   
    
# add a Button
$newButton = Button.new()
$newButton.width = 250
$newButton.height = 25
$newButton.content = "Click to write the error to debug window"
$newButton.click { |s, a| button_click(s, a) }
me.grid.children.add($newButton)
</script>

    <!-- This isn't a part of the sample, but a link back to the Gestalt site -->
    <div id="upsell" style="color:#fff; font-size: 13px; font-family:'Lucida Grande','Lucida Sans Unicode',Helvetica,Arial,Lucida,Verdana,sans-serif; margin-bottom: 30px;">
        <a href="http://www.visitmix.com/labs/gestalt/samples/" style="background-color: #000; color: #fff; display: block; text-decoration: none;" onmouseover="this.style.color='#000'; this.style.background='#ccc'" onmouseout="this.style.color='#fff'; this.style.background='#000'">
		    <span style="display:block; padding: 8px; text-align:center;">&laquo; Check out other samples on the Gestalt web site</span>
	    </a>
    </div>

    <xml id="TODO" class="xaml" width="300" height="100">
        <Grid x:Name="grid"  Width="300" Height="100">
	    </Grid>
    </xml>
    
</body>
</html>
